<template>
  <div class="video-list">
    <ul class="body-group">
      <li class="body-item" v-for="(item,index) in data" :key="index"
        @click="itemClick(item,index)">
        <!-- <router-link> -->
        <img class="item-img" v-lazy="item.data.coverUrl" />
        <span class="item-span" v-if="item.title !== null">{{ item.data.title }}</span>
        <span class="item-span" v-if="item.title == null">{{ item.data.name }}</span>
        <!-- </router-link> -->
      </li>
    </ul>
  </div>
</template>

<script>

  export default {
     props: {
      data: {
        type: Array,
        default: []
      },
    },

    // data() {
    //   return {
    //     dataList: this.data
    //   }
    // },
    created() {
      console.log("data",this.data)
    },

    methods:{
      itemClick(item,index){
        console.log(item);
        let videoInfo = item.data;
        this.$router.push({path: '/playvideo/' + videoInfo.vid})
      }
    }
  }
</script>

<style scoped>
.video-list {
  width: 100%;
  margin: auto;
}

.body-group {
  width: 100%;
  padding: 0 10px;
  box-sizing: border-box;
  display: flex;
  flex-wrap: wrap;
  /* justify-content: space-between; */
}

.body-item {
  width: 30%;
  display: inline-block;
  margin-bottom: 15px;
  height: auto;
  flex: 0 0 30%;
  font-size: 14px;
  padding: 0 5px 0 5px;
}

.item-span {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.item-img,
.item-span {
  width: 100%;
  border-radius: 5px;
  color: rgb(80, 80, 80);
}

a {
  text-decoration: none;
  color: black;
}

</style>